﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;

namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class CTHDBanSiBlo
    {
        #region "Khai báo các biến"
        private CTHDBanSiDAO da;
        private CTHDBanSiDTO _CTHDBS;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public CTHDBanSiDTO CTHDBS
        {
            get { return _CTHDBS; }
            set { _CTHDBS = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public CTHDBanSiBlo()
        {
            _CTHDBS = new CTHDBanSiDTO();
            da = new CTHDBanSiDAO();
        }
        public bool InsertCTHDBS(string MaMH, string MaHDBS, double DonGia, int SoLuong, float ChietKhau, double ThanhTien)
        {
            CTHDBS = new CTHDBanSiDTO(MaMH, MaHDBS, DonGia, SoLuong, ChietKhau, ThanhTien);
            if (!da.InsertCTHDBS(CTHDBS))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateCTHDBS(string MaMH, string MaHDBS, double DonGia, int SoLuong, float ChietKhau, double ThanhTien)
        {
            CTHDBS = new CTHDBanSiDTO(MaMH, MaHDBS, DonGia, SoLuong, ChietKhau, ThanhTien);
            if (!da.UpdateCTHDBS(CTHDBS))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteCTHDBS(string MaMH,string MaHDBS)
        {
            if (!da.DeleteCTHDBS(MaMH, MaHDBS))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_CTHDBanSi()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_CTHDBanSi();
            return ds;
        }
        #endregion
    }
}